#

| Chapter 20 Backing Up Files |

## 20.13 SCCS Basics

If you don't know SCCS, you probably thought it was hard to learn. Not true. Here is a simple introduction to SCCS.

1. Create a subdirectory called SCCS in the directory where you keep the code or other text files you want to protect.

2. Add the characters `%W% %G%` somewhere in the file you want to place under SCCS. Put this in a comment field. That is, use `/* %W% %G% */` in a C program and `# %W% %G%` in a shell script.

3. Place the file under source code control. This is done by typing:

   >     % sccs create filename

That's it. You're done. There are three more commands you need to know:

>     % sccs get filename
>     % sccs edit filename
>     % sccs delta filename

You may also want to add the following to your list of aliases (10.2):

>     C shell      ksh, bash
>     alias Create 'sccs create'           alias Create='sccs create'
>     alias Get 'sccs get'                 alias Get='sccs get'
>     alias Edit 'sccs edit'               alias Edit='sccs edit'
>     alias Delta 'sccs delta'             alias Delta='sccs delta'

The get command will get a copy of the file from the Source Code Control System. The file will be marked read-only (22.2). If you want to edit the file, use the edit command. Once you are done, return the file to the SCCS directory with the command delta. Each time you store the file, you'll get a new version number, or "delta."

There are only two more commands that you will need to know. If you checked out a file for editing, and later on decided you didn't want to edit, use:

>     % sccs unedit filename

and if you want a list of all files currently checked out, use:

>     % sccs check

That's all there is to it! If you are not using SCCS, you should. It is the best way to protect yourself. It does not require dozens of tapes.

It is much easier to just type:

>     % sccs get -r1.12 filename

One command, and version 1.12 is restored. If it's not the right one, restore the version before or after the one you just grabbed. If you are worried that you are keeping 12 versions of the file on the disk, and that this will use up a lot of disk space, don't. SCCS stores the differences in a clever manner that allows it to recover any version of the file in a single pass through the file.

Suppose you delete a file by accident? Well, if the file is just checked out with a get, it will be retrieved and marked read-only, so deleting the file will cause rm to ask you for confirmation. If you do delete it, you can recover it with another get command. Suppose you check out a file with edit, because you planned to change it. Well, if this file gets deleted accidentally, you would lose the most recent changes. This is why you should check your files back into SCCS frequently - several times a day, if you wish. Do it whenever you make significant changes to the file, and it would be difficult to remember all of the changes. Making hundreds of changes to a file without checking it back into the system is just begging for trouble.

Good luck, and may you never delete another important file by accident. [There are several other revision control systems - including RCS (20.14), which is widely used and available on the CD-ROM. You can probably get the most help on whatever revision control system your colleagues use. Also see O'Reilly & Associates' Applying RCS and SCCS. -JP ]

- BB

20.12 Protecting Files with SCCS or RCS |  | 20.14 RCS Basics